package com.mmd.manage.web;


import com.mmd.bean.CODE;
import com.mmd.bean.WebJsonBean;
import com.mmd.manage.service.DeliveryService;
import com.mmd.manage.vo.QueryDeliveryListEo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@RequestMapping(value = "/api/delivery")
@Controller
public class DeliveryController {

    @Autowired
    private DeliveryService deliveryService;


    /**
     * 生成提单号
     *
     * @return
     */
    @RequestMapping(value = "/saveDeliveryNo")
    @ResponseBody
    public WebJsonBean saveDeliveryNo(String batchNos, String deliveryNo) {
        return new WebJsonBean(CODE.SUCCESS, deliveryService.saveDeliveryNo(batchNos, deliveryNo));
    }

    /**
     * 查询提单列表
     *
     * @return
     */
    @RequestMapping(value = "/queryDeliveryList")
    @ResponseBody
    public WebJsonBean queryDeliveryList(QueryDeliveryListEo eo) {
        return new WebJsonBean(CODE.SUCCESS, deliveryService.queryDeliveryList(eo));
    }

    /**
     * 查询提单的物流轨迹
     *
     * @return
     */
    @RequestMapping(value = "/queryDeliveryTrackList")
    @ResponseBody
    public WebJsonBean queryDeliveryTrackList(String deliveryNo) {
        return new WebJsonBean(CODE.SUCCESS, deliveryService.queryDeliveryTrackList(deliveryNo));
    }

    /**
     * 保存提单的物流轨迹
     *
     * @return
     */
    @RequestMapping(value = "/saveDeliveryTrack")
    @ResponseBody
    public WebJsonBean saveDeliveryTrack(String deliveryNo, Integer dictKey, String content) {
        return new WebJsonBean(CODE.SUCCESS, deliveryService.saveDeliveryTrack(deliveryNo, dictKey, content));
    }

    /**
     * 删除提单的物流轨迹
     *
     * @return
     */
    @RequestMapping(value = "/deleteDeliveryTrack")
    @ResponseBody
    public WebJsonBean deleteDeliveryTrack(Long trackId) {
        return new WebJsonBean(CODE.SUCCESS, deliveryService.deleteDeliveryTrack(trackId));
    }
}
